import { createAction } from 'redux-actions';
import * as types from '../constants/ActionTypes';
import * as Api from '../utils/WebAPIUtils.js';
import Tool from '../utils/ToolUtils.js';

const getTestResultAction = createAction(types.FETCH_TEST_RESULT, data => data);
const updateOneTestResultAction = createAction(types.UPDATE_ONE_TEST_RESULT, data => data);
const getResultDetailAction = createAction(types.FETCH_RESULT_DETAIL, data => data);
// const getpushCategoryLogAction = createAction(types.FETCH_PUSH_CATEGORY_LOG, data => data);
// const saveMsg = createAction(types.SAVE_ERROR_MSG, data => data);

exports.fetchTestResultList = (data) => (dispath) =>
  Tool.post(Api.testResult.query, data, (res) => {
    dispath(getTestResultAction(res));
  });

exports.updateOneTestResult = (data) => (dispath) =>
  Tool.post(Api.testResult.refurbish, data, (res) => {
    dispath(updateOneTestResultAction(res));
  });
exports.fetchResultDetail = (data) => (dispath) =>
  Tool.post(Api.testResult.getResult, data, (res) => {
    dispath(getResultDetailAction(res));
  });
